<template>
  <a-modal
    title="新增"
    :maskClosable="false"
    :width="1050"
    placement="right"
    :closable="true"
    @cancel="onClose"
    :footer="null"
    :visible="mchntLevelAddVisiable"
  >
    <a-form :form="form">
      <a-row>
        <a-col :md="12" :sm="24"
          ><a-form-item label="商户等级名称" v-bind="formItemLayout">
           <a-input  v-decorator="[
                'mchntLevelName',
                { rules: [{ required: true, message: '不能为空' }] },
              ]"></a-input>
              </a-form-item>
              </a-col>
        <a-col :md="12" :sm="24"
          ><a-form-item label="商户等级描述" v-bind="formItemLayout">
            <a-input
              v-decorator="[
                'mchntLevelDesc']"
            /> </a-form-item
        ></a-col>
      </a-row>
    </a-form>
    <div class="drawer-bootom-button">
      <a-button @click="handleSubmit" type="primary" :loading="loading"
        >保存
      </a-button>
      <a-button style="margin-left: 0.8rem" @click="onClose">取消</a-button>
    </div>
  </a-modal>
</template>
<script>
const formItemLayout = {
  labelCol: { span: 6 },
  wrapperCol: { span: 15 },
};
export default {
  name: "MchntLevelAdd",
  props: {
    mchntLevelAddVisiable: {
      default: false,
    },
  },
  data() {
    return {
      mchntLevel: {},
      loading: false,
      roleData: [],
      formItemLayout,
      form: this.$form.createForm(this),
    };
  },
  methods: {
    reset() {
      this.loading = false;
      this.form.resetFields();
    },
    onClose() {
      this.reset();
      this.$emit("close");
    },
    handleSubmit() {
      this.form.validateFields((err, values) => {
        if (!err) {
          this.setMchntLevelFields();
          this.loading = true;
          this.mchntLevel.roleId = this.mchntLevel.roleId.join(",");
          // this.$post('mchntLevel', {
          //   ...this.mchntLevel
          // }).then((r) => {
          //   this.reset()
          //   this.$emit('success')
          // }).catch(() => {
          //   this.loading = false
          // })
        }
      });
    },
handleChange(){},
    setMchntLevelFields() {
      let values = this.form.getFieldsValue(["dstChannelId", "dstChannelName"]);
      if (typeof values !== "undefined") {
        Object.keys(values).forEach((_key) => {
          this.mchntLevel[_key] = values[_key];
        });
      }
    },
  },
  watch: {},
};
</script>
